﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LLFM.CAT.Model;
using LLFM.CAT.Service;
using Common;
using LLFM.CAT.Enum;

public partial class Product_SeriesDetail : PageBase
{
    protected int SeriesId { get { return RequestHelper.GetInt("seriesid",0); } }
    protected M_Series Series { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        navuc.CurrentTagLevelOne = 2;
        navuc.CurrentTagLevelTwo = 2 * 10 + SeriesId;
        Series = SeriesService.GetSeriesById(SeriesId);
        InitBread();
        string[] seriesAdvantages = Series.Advantage.Split(new string[]{"|"},StringSplitOptions.RemoveEmptyEntries);
        ltlSeriesAdvantage.Text = string.Empty;
        for (int i = 0; i < seriesAdvantages.Length; i++)
        {
            ltlSeriesAdvantage.Text += "<li>";
            ltlSeriesAdvantage.Text += seriesAdvantages[i];
            ltlSeriesAdvantage.Text += "</li>";
        }
        List<M_Products> productList = ProductsService.GetProductListBySeriesIdOrderbyIdDesc(SeriesId,1,100);
        rptSeriesDetailImageBigList.DataSource = productList;
        rptSeriesDetailImageBigList.DataBind();
        rptList.DataSource = productList;
        rptList.DataBind();
    }

    protected void rptListDataBound(object sender, RepeaterItemEventArgs e) 
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            M_Products product = (M_Products)e.Item.DataItem;
            //M_ProductExtention productExtention = ProductExtentionService.GetProductExtentionByProductId(product.Id);
            Literal ltlLink = (Literal)e.Item.FindControl("ltlLink");
            ltlLink.Text = " <a class='btn-download' target='_blank' href='" + product.UserManual+ "'>下载产品手册</a>";
        }
    }

    private void InitBread()
    {
        Dictionary<string, string> dic = new Dictionary<string, string>();
        dic.Add("首页", "../Index.aspx");
        dic.Add("挖机产品", "../Product/SeriesDetail.aspx");
        dic.Add(Enum.GetName(typeof(SeriesEnum), SeriesId), "../Product/SeriesDetail.aspx?seriesid=" + SeriesId);
        bread1.dic = dic;
    }
}